/*-----------------------------------------------------------------------------
 DoubleDiscActivity.java - Gets the second discount amount.  
 Copyright (C) 2011 z0ltrix aka Amit Parmar

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-----------------------------------------------------------------------------*/

package com.z0ltrix.DiscountCalcr;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;

public class DoubleDiscActivity extends Activity {

	TextView mDisplayText;
	TextView mDisplayDiscount;
	SeekBar mSeekDoubleDisc;
	Button mDoneButton;
	int DISCOUNT = 0;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);

		setContentView(R.layout.doubledisclayout);

		Intent discData = getIntent();
		DISCOUNT = discData.getIntExtra("DISCOUNT", 0);

		mDisplayDiscount = (TextView) findViewById(R.id.DoubleDiscValueTextid);
		mDisplayText = (TextView) findViewById(R.id.DoubleDiscActivity_Textid);
		mDisplayText.setText(getString(R.string.DoubleDiscAcitivity_text));

		mSeekDoubleDisc = (SeekBar) findViewById(R.id.DoubleDiscActivity_Seekbarid);
		mSeekDoubleDisc.setProgress(DISCOUNT);
		mDisplayDiscount.setText(getString(R.string.DoubleDiscValueText,
				DISCOUNT));
		mSeekDoubleDisc
				.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

					public void onStopTrackingTouch(SeekBar seekBar) {
						// TODO Auto-generated method stub

					}

					public void onStartTrackingTouch(SeekBar seekBar) {
						// TODO Auto-generated method stub

					}

					public void onProgressChanged(SeekBar seekBar,
							int progress, boolean fromUser) {

						DISCOUNT = progress;
						mDisplayDiscount.setText(getString(
								R.string.DoubleDiscValueText, DISCOUNT));

					}
				});

		mDoneButton = (Button) findViewById(R.id.DoubleDiscActivity_Buttonid);

		mDoneButton.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {

				Intent i = getIntent();
				i.putExtra("discountValue", DISCOUNT);
				setResult(RESULT_OK, i);

				finish();

			}
		});

	}

}
